package com.medical.Controller.admin;

import com.medical.DTO.MedicalReportsDTO;
import com.medical.DTO.MedicalReportsPageDTO;
import com.medical.Service.MedicalReportsService;
import com.medical.result.PageResult;
import com.medical.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin("*")
@Tag(name = "医疗报告管理类")
@RequestMapping("/api/admin")
@Slf4j
public class MedicalReportsController {
    @Autowired
    private MedicalReportsService medicalReportsService;

    /*
    * 添加医疗报告
     */
    @Operation(summary = "添加医疗报告")
    @PostMapping("/addMedicalReports")
    public Result addMedicalReports(@RequestBody MedicalReportsDTO medicalReportsDTO) {
        medicalReportsService.addMedicalReports(medicalReportsDTO);
        return Result.success();
    }

    /*
    * 删除医疗报告
     */
    @Operation(summary = "删除医疗报告")
    @DeleteMapping("/deleteMedicalReports/{ids}")
    public Result deleteMedicalReports(@PathVariable List<Integer> ids) {
        medicalReportsService.deleteMedicalReports(ids);
        return Result.success();
    }

    /*
    * 修改医疗报告
     */
    @Operation(summary = "修改医疗报告")
    @PutMapping("/updateMedicalReports")
    public Result updateMedicalReports(@RequestBody MedicalReportsDTO medicalReportsDTO) {
        medicalReportsService.updateMedicalReports(medicalReportsDTO);
        return Result.success();
    }

    /*
    * 获取医疗报告列表
     */
    @Operation(summary = "获取医疗报告列表")
    @GetMapping("/pageReportsList")
    public Result getMedicalReportsList(MedicalReportsPageDTO medicalReportsPageDTO) {
     PageResult page = medicalReportsService.page(medicalReportsPageDTO);
        return Result.success(page);
    }

}
